package com.pzr.soccer.task.config;


import com.pzr.soccer.task.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * web应用关闭后，用来关闭全部的线程池里面的任务
 * @Author pzr
 * @date:2021-12-23-10:37
 * @Description:
 **/
@Component
public class TaskListener implements ServletContextListener {
    @Autowired
    TaskService taskService;
    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("关闭任务线程");
        taskService.stopAllTasks();
    }
}
